package com.tj.collection.db.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.tj.collection.db.dao.ClStageDao;
import com.tj.collection.db.entity.ClStageEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2019-09-03
 * Time: 10:28
 */
@Repository
public class ClStageDaoImpl extends AbstractBaseMapper<ClStageEntity> implements ClStageDao {

    @Override
    public List<ClStageEntity> getStagesByMerchantCode(String merchantCode) {
        Map<String, Object> map = new HashMap<>();
        map.put("merchantCode", merchantCode);
        return getSqlSession().selectList(this.getStatement("getStagesByMerchantCode"), map);
    }

    @Override
    public ClStageEntity getStagesByMerchantCodeAndOverdueDays(String merchantCode, Integer overdueDays) {
        Map<String, Object> map = new HashMap<>();
        map.put("merchantCode", merchantCode);
        map.put("overdueDays", overdueDays);
        return getSqlSession().selectOne(this.getStatement("getStagesByMerchantCodeAndOverdueDays"), map);
    }

    @Override
    public ClStageEntity getStageByStageCode(String merchantCode, String stageCode) {
        Map<String, Object> map = new HashMap<>();
        map.put("merchantCode", merchantCode);
        map.put("stageCode", stageCode);
        return getSqlSession().selectOne(this.getStatement("getStageByStageCode"), map);
    }

    @Override
    public ClStageEntity getStageByStageName(String merchantCode, String stageName) {
        Map<String, Object> map = new HashMap<>();
        map.put("merchantCode", merchantCode);
        map.put("stageName", stageName);
        return getSqlSession().selectOne(this.getStatement("getStageByStageName"), map);
    }

    @Override
    public List<ClStageEntity> selectMStages() {
        Map<String, Object> map = new HashMap<>();
        return getSqlSession().selectList(this.getStatement("selectMStages"), map);
    }
}
